<?php 

namespace pmvc;
use pmvc\ioc\xml\XmlObjectFactory;
use pmvc\util\ReflectionUtil;

use Exception;

class XmlApplicationContext 
	extends XmlObjectFactory
	implements ApplicationContext {

	/**
	 * Creates the {@link ApplicationContext}.
	 * @param mixed $objectFactory an ObjectFactory, array of files or a single file
	 * @param unknown_type $classPath
	 */
	public function __construct($objectFactory) {
		// an actual ObjectFactory
		if (ReflectionUtil::isInstance($objectFactory, 'pmvc\ioc\ObjectFactory')) {
			parent::__construct(Array(), $objectFactory);

		// an array of ObjectFactory files
		} else if (is_array($objectFactory)) {
			parent::__construct($objectFactory);
	
		// a single file
		} else if (is_string($objectFactory)) {
			parent::__construct(Array($objectFactory));

		// wtf
		} else {
			throw new Exception("Unable to determine \$objectFactory type: ".print_r($objectFactory, 1));
		}

		// intialize
		parent::initialize();
	}

}

?>